package com.seckill.act.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 * @author 作者
 * @since 2022-03-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_activity")
////@ApiModel(value="Activity", description="")
public class Activity implements Serializable {

    @TableId(value = "id",type = IdType.ASSIGN_ID)
    private String id;

    @TableField("name")
    private String name;

    ////@ApiModelProperty(value = "状态：1开启，2未开启")
    @TableField("status")
    private Integer status;

    @TableField("startdate")
    private Date startdate;

    ////@ApiModelProperty(value = "开始时间，单位：时分秒")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("begintime")
    private Date begintime;

    ////@ApiModelProperty(value = "结束时间，单位：时分秒")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("endtime")
    private Date endtime;

    @TableField("total_time")
    private Float totalTime;

    ////@ApiModelProperty(value = "删除：1未删除，2已删除")
    @TableField("is_del")
    private Integer isDel;

    @TableField("time_id")
    private Integer timeId;

    //时间信息
    @TableField(exist = false)
    private SeckillTime seckillTime;

    //状态
    public String getStart(){
        return endtime.getTime()<System.currentTimeMillis()? "已结束":
                startdate.getTime()>System.currentTimeMillis()? "未开始":"进行中";
    }


    //获取字符串时间
    public String getBgstr(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
        return simpleDateFormat.format(this.begintime);
    }
    public String getFullBgstr(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return simpleDateFormat.format(this.begintime);
    }
    public String getEndstr(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
        return simpleDateFormat.format(this.endtime);
    }
    public String getFullEndstr(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return simpleDateFormat.format(this.endtime);
    }
    public String getShTime(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
        return simpleDateFormat.format(this.begintime);
    }

    //开始还是结束
    public int getLookStatus(){
        long now = System.currentTimeMillis();
        long bt = this.begintime.getTime();
        long ed = this.endtime.getTime();
        if(this.begintime.getTime()<now && this.endtime.getTime()>now){
            //进行中
            return 1;
        }
        if(this.begintime.getTime()>now){
            //未开始
            return 2;
        }
        return 3;
    }
}
